#include<stdio.h>
__int64 g(__int64 a,__int64 b)
{
__int64 rem;
while(b)
{rem=a%b;a=b;b=rem;}
return a;
}
int main()
{
__int64 k,a,c,b,d,m,n;char t;
scanf("%I64d",&k);
while(k--)
{
scanf("%I64d%c%I64d",&a,&t,&c);
scanf("%I64d%c%I64d",&b,&t,&d);
m=c*d/g(c,d);
a*=m/c;b*=m/d;
n=a*b/g(a,b);a=g(n,m);n/=a;m/=a;
if(m!=1)printf("%I64d/%I64d\n",n,m);
else
printf("%I64d\n",n);
}}
